#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
使用raise抛出错误
错误可以自定义
"""


class FooError(ValueError):
    pass


def foo(s):
    n = int(s)
    if n == 0:
        raise FooError('foo:invalid value :%s' % s)
    return 10 / n


def main():
    try:
        foo('0')
    except Exception as e:
        print('Exception:', e)


if __name__ == "__main__":
    main()
